/**
 * 
 */
package masterlink.futures.vo;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * @author tonyyang
 *
 */
@Entity
@Table(name="SYS_EMP_GROUP")
public class EmpGroup implements Serializable {

	private static final long serialVersionUID = -1830152881458729283L;
	
	@EmbeddedId
	private ID id;
	@Column(name="phone")
	private String phone;
	@Column(name="SEND_SMS")
	private String send;
	/**
	 * @return the id
	 */
	public ID getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(ID id) {
		this.id = id;
	}
	/**
	 * @return the phone
	 */
	public String getPhone() {
		return phone;
	}
	/**
	 * @param phone the phone to set
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}
	/**
	 * @return the send
	 */
	public String getSend() {
		return send;
	}
	/**
	 * @param send the send to set
	 */
	public void setSend(String send) {
		this.send = send;
	}
	public boolean send(){
		return !"N".equalsIgnoreCase(send);
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("EmpGroup [id=");
		builder.append(id);
		builder.append(", phone=");
		builder.append(phone);
		builder.append(", send=");
		builder.append(send);
		builder.append("]");
		return builder.toString();
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		EmpGroup other = (EmpGroup) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	@Embeddable
	public static class ID implements Serializable{
		
		private static final long serialVersionUID = 3607513383764618839L;
		@Column(name="EMPNO")
		private String empno;
		@ManyToOne(fetch=FetchType.EAGER)
		private Group group;
		/**
		 * @return the empno
		 */
		public String getEmpno() {
			return empno;
		}
		/**
		 * @param empno the empno to set
		 */
		public void setEmpno(String empno) {
			this.empno = empno;
		}
		/**
		 * @return the group
		 */
		public Group getGroup() {
			return group;
		}
		/**
		 * @param group the group to set
		 */
		public void setGroup(Group group) {
			this.group = group;
		}
		/* (non-Javadoc)
		 * @see java.lang.Object#toString()
		 */
		@Override
		public String toString() {
			StringBuilder builder = new StringBuilder();
			builder.append("ID [empno=");
			builder.append(empno);
			builder.append(", group=");
			builder.append(group);
			builder.append("]");
			return builder.toString();
		}
		/* (non-Javadoc)
		 * @see java.lang.Object#hashCode()
		 */
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + ((empno == null) ? 0 : empno.hashCode());
			result = prime * result + ((group == null) ? 0 : group.hashCode());
			return result;
		}
		/* (non-Javadoc)
		 * @see java.lang.Object#equals(java.lang.Object)
		 */
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			ID other = (ID) obj;
			if (empno == null) {
				if (other.empno != null)
					return false;
			} else if (!empno.equals(other.empno))
				return false;
			if (group == null) {
				if (other.group != null)
					return false;
			} else if (!group.equals(other.group))
				return false;
			return true;
		}
		
	}

}
